#三、编程题 （5分）
# 1.统计姓张的有几人
# tp1 = (("1","张三","18"), ("2","李四","19"), ("3","王五","20"),("4","张涛","20"))
# #方法1：
# zhang=[ i[1][0] for i in tp1]
# print(zhang.count("张"))
# #方法2：
# count=0
# for zhang in tp1:
#    if zhang[1].startswith("张"):
#        count+=1
# print(count)
# 四、编程题 （5分）
# user = [["1","张三","18"], ["2","李四","19"], ["3","王五","20"], ["4","张涛","20"]]
# # 1统计年龄大于19岁的有几人：
# count =0
# for u in user:
#    if int(u[2]) >19:
#        count +=1
# print(count)
# 五、编程题 （5分）把如下user信息写入文件,打开文件后的展示如下，补充代码：

# user=(("1","张三","18"), ("2","李四","19"), ("1","王五","20"))
#
# #方法一
# user_write=[",".join(u)+"\n"for u in user]
# print(user_write)
# file=open("myuser",mode="w",encoding="utf8")
# file.writelines(user_write)
# file.close()
#
# #方法二
# import csv
#
# file =open("myuser",mode="w",encoding="utf8",newline="")
# csv_write = csv.writer(file,delimiter=",")
# csv_write.writerows(user)
# file.close()
# 六、编程题（6分）把如下user信息读取到python变量userinfo中 （注意读取后年龄是整数格式）

#方案一：
# data=file.readlines()
# for i in range(len(data)):
#    data[i]=data[i].strip("\n")
#    data[i]=data[i].split(",")
#    data[i][2]=int(data[i][2])
#
# print(data)

#方案二
# import csv
#
# csv_read=csv.reader(file,delimiter=",")
# data=list(csv_read)
#
# for i in range(len(data)):
#    data[i][2]=int(data[i][2])
# print(data)
#
# file.close()
# print(userinfo)# [['1', '张三', 18], ['2', '李四', 19], ['1', '王五', 20]]
